<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<title>无忧微贷</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css">
		<link rel="stylesheet" type="text/css" href="../css/common.css">
		<link rel="stylesheet" type="text/css" href="../css/icomoon/style.css">
		<script type="text/javascript" src="../js/rem.js"></script>
	</head>
	<body>
		<div class="m-password m-common">
			<h3 class="header f-pr">
				<span>重置登录密码</span>
				<i class="icon-angle-left f-pa"></i>
			</h3>
			<ul>
				<li>
					<label>新密码</label>
					<input type="password" class="password" placeholder="含字母和数字的6-16位字符">
					<i class="close-icon f-pa"></i>
					<i class="unsee-icon f-pa"></i>
				</li>
				<li>
					<label>确认密码</label>
					<input type="password" class="confirmpwd" placeholder="再次输入新密码">
					<i class="close-icon f-pa"></i>
					<i class="unsee-icon f-pa"></i>
				</li>
			</ul>
			<div class="btn-box">
				<a class="btn">下一步</a>
			</div>
			<p class="tips">如有疑问，请联系客服：<span>0755-22217999</span></p>
		</div>
		<script type="text/javascript" src="../js/md5.min.js"></script>
		<script type="text/javascript" src="../js/zepto.min.js"></script>
		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>

		<script type="text/javascript">
			mui.plusReady(function(){
				function validate(){
					var pwd = $('.password').val(), conpwd = $('.confirmpwd').val();
					if(pwd == ''){
						mui.toast('请输入含字母和数字的6-16位字符的密码');
						return false;
					}else if(pwd.length < 6 || pwd.length > 16){
						mui.toast('密码只能是含字母和数字的6-16位字符');
						return false;
					}

					if(conpwd == ''){
						mui.toast('请再次输入密码');
						return false;
					}else if(conpwd != pwd){
						mui.toast('两次输入的密码不一致');
						return false;
					}
					return true;
				}

				$('.btn').on('tap', function(){
					mui.ajax(base + 'passport/resetpassword', {
						type: 'post',
						data: {
							'sign': plus.webview.currentWebview().sign,
							'password': $.trim($('.password').val()),
							'confirm': $.trim($('.confirmpwd').val())
						},
						dataType: 'json',
						headers: sign(md5),
						success: function(data){
							if(data.result){
								mui.toast('登录密码修改成功');
								plus.webview.getWebviewById('findpassword.html').close();
								setTimeout(function(){
									plus.webview.currentWebview().close();
								}, 1000);
							}
						},
						error: function(data){
							console.error(data.message);
						}
					});
				});

				$('.icon-angle-left').on('tap', function(){
					mui.back();
				});

				$('.password, .confirmpwd').on('keyup', function(){
					var value = $(this).val();
					if(value){
						$(this).siblings('.unsee-icon').show();
					}else{
						$(this).siblings('.unsee-icon').hide();
					}
				});
			});
		</script>
	</body>
</html>